#include <algorithm>

namespace Tvimeg
{
	static inline std::string ltrim(const std::string& s)
	{
		return std::string(std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))), s.end());
	}

	static inline std::string rtrim(const std::string& s)
	{
		return std::string(s.begin(), std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base());
	}

	static inline std::string trim(const std::string& s)
	{
		return ltrim(rtrim(s));
	}

	static inline std::string tolower(const std::string& s)
	{
		std::string result(s);
		std::transform(result.begin(), result.end(), result.begin(), ::tolower);
		return result;
	}

	static inline std::string toupper(const std::string& s)
	{
		std::string result(s);
		std::transform(result.begin(), result.end(), result.begin(), ::toupper);
		return result;
	}
}
